// pt.C -- post ta pid
void pt(){
  TFile *f = new TFile(getenv("TMP1"), "UPDATE");
  TTree *etf = (TTree *)f->Get("etf");
  TCutG *az_[4] = {(TCutG *)f->Get("ca21"), (TCutG *)f->Get("ca22"),
    (TCutG *)f->Get("ca23"), (TCutG *)f->Get("ca24")};
  TCut cut = "1 "
    "&& x_f1>=-17.&&x_f1<=-11. "
    "&& pdcTaUWire[1][0]>=-15.&&pdcTaUWire[1][0]<=-1. "
    "&& z0c>=19.5 && z0c<=20.5"
    "&& sqrt((pTAU[0]+7.)*(pTAU[0]+7.)+(pTAU[1]+1.5)*(pTAU[1]+1.5))<25. " // within TA
    // "&& (ca21 || ca22 || ca23 || ca24) "
  ;

  // etf->Draw("et.tof1:et.tof2>>h1(1000, 40., 130., 1000, 110., 170.)", cut);
  etf->Draw("x_f1>>h1(52, -52., 52.)", cut);
  // etf->Draw("pid.trkLenT():pid.tof2()>>h2(1000, 40., 130., 1000, 11300., 11440.)", cut);
  etf->Draw("pdcTaUWire[1][0]>>h2(36, -45., 45.)", cut);
  etf->Draw("z0c>>h3(1000, 14., 39.)", cut);
  etf->Draw("z0c:aoz0c>>h4(300, 1.8, 2.4, 300, 14., 39.)", cut);
  // etf->Draw("et.tof2>>h5(1000, 40., 130.)", cut);
  // etf->Draw("pid.beta()>>h6(1000, 0.2, 0.8)", cut);
  etf->Draw("et.tof2:aoz0c>>h5(300, 1.95, 2.3, 300, 60., 80.)", cut);
  etf->Draw("pid.beta():aoz0c>>h6(300, 1.95, 2.3, 300, 0.45, 0.65)", cut);

  TCanvas *c1 = new TCanvas("c", "Tstop Statistics", 1680, 1050);
  c1->Divide(3,2); char h[64]; TH1 *b;
  for(int i = 0; i < 6; i++){
    sprintf(h, "h%d", i+1); f->GetObject(h,b);
    c1->cd(i+1)->SetGrid(); b->Draw("colz");
  } // end for
  c1->Print("pt.pdf");
} // end pt
